package com.sky.kafkaDemo.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.kafkaDemo.entity.User;
import com.sky.kafkaDemo.mapper.UserMapper;
import com.sky.kafkaDemo.service.IUserService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2024/11/24 21:38
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public List<User> getUserByCondition(String userName, Integer status, Integer balance) {
        List<User> list = lambdaQuery()
                // 当userName不为空时才查此userName字段
                .like(StringUtils.isNotEmpty(userName), User::getUserName, userName)
                // 当状态不为空时才查状态字段
                .eq(status != null, User::getStatus, status)
                // 当余额不为空时才查余额字段
                .ge(balance != null, User::getBalance, balance)
                //.one();   // 查一个
                //.count(); // 统计
                //.exists();// 是否存在
                //.page()   // 分页
                .list();

        return list;
    }

}
